<?php
require_once "./db_config.php";
$arr=[];
if(isset($_POST['status'])){
    $status=$_POST['status'];
    if($status=='0'){
        $sql="SELECT * FROM dynamic_form WHERE `delete`!='1'";
    }else if($status=='1'){
        $name=$_POST['name'];
        $sql="SELECT * FROM dynamic_form_properties WHERE belongTo='$name'&&`delete`!='1'";
//        echo $sql;
    }else if($status=='0.1'){
        $sql="SELECT name FROM dynamic_form WHERE `delete`!='1'";
    }else if($status=='2'){
        $id=$_POST['id'];
        $name=$_POST['name'];
        $sql="SELECT attributeJSON FROM dynamic_form_list WHERE id='$id' AND belongTo='$name' ";
    }
    $result=mysqli_query($conn,$sql);
    if(mysqli_num_rows($result) > 0){
        while($row = mysqli_fetch_assoc($result)) {
            $arr[]=$row;
        }
        echo json_encode($arr,JSON_UNESCAPED_UNICODE);
    }else{
        echo "ERROR!";
    }
}
mysqli_close($conn);
